import sys
import os
from PyQt4 import QtGui
from PyQt4 import QtCore        
        
class ERDialog(QtGui.QWidget):
    def __init__(self, title, dataMsg, parent=None):
        QtGui.QWidget.__init__(self, parent)
        
        self.title = title
        self.dataMsg = dataMsg
        
        #tootip
        self.setToolTip('Message')
        QtGui.QToolTip.setFont(QtGui.QFont('Arial', 10))
        self.setWindowIcon(QtGui.QIcon('d:\pyx\Bug.png'))

        self.setGeometry(500, 300, 250, 150)
        self.setWindowTitle(title)
        screen = QtGui.QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 3, (screen.height() - size.height()) / 3)
        self.setFixedSize(500,300)
	
	#GROUP LAYOUT
	#self.hbox = QtGui.QHBoxLayout()
	#self.hbox.addStretch(1)
	
	basepath_pre = os.path.realpath(sys.argv[0])
	basepath = os.path.split(basepath_pre)
        self.imgInfo = QtGui.QImage(basepath[0] + '/images/Alert.png')
        self.imageLabel = QtGui.QLabel(self)
	#self.imageLabel.setMinimumSize(200, 200)
	#self.imageLabel.setMaximumSize(100,100)
	self.imageLabel.setGeometry(5, 5, 125, 125)
        self.imageLabel.setPixmap(QtGui.QPixmap.fromImage(self.imgInfo))
	
	self.wrk = QtGui.QWorkspace(self)
        #self.wrk.setMinimumSize(480, 250)
        self.wrk.setGeometry(130, 5, 360, 250)
        self.wrk.setScrollBarsEnabled(True)
	
	#self.labelInfo = QtGui.QLabel(self.wrk)
	#self.labelInfo.setFont(QtGui.QFont('Arial', 20))
	#self.labelInfo.setText(self.dataMsg)
	#self.labelInfo.setGeometry(133, 0, 350, 50)
	#self.labelInfo.setGeometry(1, 0, 350, 50)
	
	#self.hbox.addWidget(self.imageLabel)
	#self.hbox.addWidget(self.labelInfo)
	
	#vbox = QtGui.QVBoxLayout()
        #vbox.addStretch(1)
        #vbox.addLayout(self.hbox)

        #self.setLayout(self.hbox)
        
        
        
        self.result = QtGui.QTextEdit(self.wrk)
	self.result.enabledChange(False)
	self.result.e
        #self.result = QtGui.QTextEdit(self)
        self.result.setGeometry(0, 0, 360, 250)
        self.result.setFont(QtGui.QFont('Arial', 20))
        self.result.setToolTip('Result Message')
        self.result.setStatusTip('Result Message')
        self.result.setText(dataMsg)
        
        self.buttonOK = QtGui.QPushButton('OK',  self)
        self.buttonOK.setGeometry(150, 263, 80, 30)
        
        self.buttonCancel = QtGui.QPushButton('Cancel',  self)
        self.buttonCancel.setGeometry(250, 263, 80, 30)
        self.connect(self.buttonCancel,  QtCore.SIGNAL('clicked()'), QtGui.qApp, QtCore.SLOT('quit()'))

        
class MessageBox(QtGui.QWidget):
    def __init__(self, dataTitle, dataType, dataInfo, parent=None):
	self.dataTitle = dataTitle
	self.dataType = dataTitle
	self.dataInfo = dataInfo
	
        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle(self.dataTitle)


    def closeEvent(self, event):
        reply = QtGui.QMessageBox.question(self, str(self.dataType),
            str(self.dataInfo), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)

        if reply == QtGui.QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
        
class ErrorFound(Exception):
    def __init(self, dataTitle, dataER):
        self.dataEX = dataER
        self.dataET = dataTitle
        
        app = QtGui.QApplication(sys.argv)
        w = ERDialog(self.dataET, self.dataEX)
        w.show()
        sys.exit(app.exec_())
        
    
#app = QtGui.QApplication(sys.argv)
#w = ERDialog("TEST","TEST")
#w = ERDialog(ErrorFound.dataET, ErrorFound.dataEX)
#w.show()
#sys.exit(app.exec_())
        

        

        